%include "syscalls.asm"

section .data

ohx	db	"0x"
hex	db	"0123456789ABCDEF"

section .text

;; INPUT: rax
;; USES: rcx, rbx, r8 + rax,rdi,rsi,rdx
print_pointer:
	mov	rbx, rax
	
	mov	rax, sys_write
	mov	rdi, 0
	mov	rsi, ohx
	mov	rdx, 2
	syscall

	mov	r8, 8

.pp_loop:
	;; get the top nyb
	mov	rsi, rbx
	shr	rsi, 64-4
	add	rsi, hex
	mov	rax, sys_write
	mov	rdi, 0
	mov	rdx, 1
	syscall

	;; and the second top nyb
	mov	rsi, rbx
	shr	rsi, 64-8
	and	rsi, 0x0F
	add	rsi, hex
	mov	rax, sys_write
	mov	rdi, 0
	mov	rdx, 1
	syscall

	;; throw that byte away
	shl	rbx, 8

	sub	r8, 1
	jnz	.pp_loop

	ret
